home *** CD-ROM | disk | FTP | other *** search
- /*
- * Square.c
- *
- * Copyright 2000, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- *
- * UNPUBLISHED -- Rights reserved under the copyright laws of the United
- * States. Use of a copyright notice is precautionary only and does not
- * imply publication or disclosure.
- *
- * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
- * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
- * in similar or successor clauses in the FAR, or the DOD or NASA FAR
- * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
- * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
- *
- * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
- * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
- * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
- * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
- * GRAPHICS, INC.
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2
- */
- #ifdef REV_INFO
- #ifndef lint
- static char rcsid[] = "$XConsortium: Square.c /main/cde1_maint/1 1995/07/14 13:57:11 drk $"
- #endif
- #endif
-
- /*****************************************************************************
- *
- * Square.c - widget source file
- *
- ******************************************************************************/
-
- #include <stdio.h>
- #include <Xm/Xm.h>
- #include <Mrm/MrmPublic.h>
- #include <Xm/BulletinBP.h>
- #include "SquareP.h"
-
- #define Width(w) XmField((w),square_offsets,Core,width,Dimension)
- #define Height(w) XmField((w),square_offsets,Core,height,Dimension)
- #define BorderWidth(w) XmField((w),square_offsets,Core,border_width,Dimension)
- #define MajorDimension(w) XmField((w),square_offsets,Square,major_dimension,int)
-
- #define MakeSquare(w) XmConstraintField((w),square_constraint_offsets, \
- Square,make_square, Boolean)
-
- static void ClassInitialize();
- static void Initialize();
- static Boolean SetValues();
- static void ConstraintInitialize();
- static Boolean ConstraintSetValues();
-
- static XmPartResource resources[] = {
- {
- SquareNmajorDimension, SquareCMajorDimension, XmRInt, sizeof(int),
- XmPartOffset(Square,major_dimension), XmRImmediate, (XtPointer)SquareWIDTH
- }
- };
-
- static XmPartResource constraints[] = {
- {
- SquareNmakeSquare, SquareCMakeSquare, XmRBoolean, sizeof(Boolean),
- XmConstraintPartOffset(Square,make_square),
- XmRImmediate, (XtPointer)False
- }
- };
-
-
- externaldef(squareclassrec) SquareClassRec squareClassRec =
- {
- { /* core_class fields */
- (WidgetClass) &xmBulletinBoardClassRec, /* superclass */
- "Square", /* class_name */
- sizeof(SquarePart), /* widget_size */
- ClassInitialize, /* class_initialize */
- NULL, /* class init part proc */
- False, /* class_inited */
- Initialize, /* initialize */
- NULL, /* initialize_notify */
- XtInheritRealize, /* realize */
- NULL, /* actions */
- 0, /* num_actions */
- (XtResourceList)resources,/* resources */
- XtNumber(resources), /* num_resources */
- NULLQUARK, /* xrm_class */
- False, /* compress_motion */
- XtExposeCompressMaximal, /* compress_exposure */
- False, /* compress_enterleave */
- False, /* visible_interest */
- NULL, /* destroy */
- XtInheritResize, /* resize */
- XtInheritExpose, /* expose */
- SetValues, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- NULL, /* accept_focus */
- XtVersionDontCheck, /* version */
- NULL, /* callback_private */
- XtInheritTranslations, /* tm_table */
- XtInheritQueryGeometry, /* Query Geometry proc */
- NULL, /* disp accelerator */
- NULL, /* extension */
- },
-
- { /* composite_class fields */
- XtInheritGeometryManager, /* geometry_manager */
- XtInheritChangeManaged, /* change_managed */
- XtInheritInsertChild, /* insert_child */
- XtInheritDeleteChild, /* delete_child */
- NULL, /* extension */
- },
-
- { /* constraint_class fields */
- (XtResourceList)constraints, /* constraint resource */
- XtNumber(constraints), /* number of constraints */
- sizeof(SquareConstraintPart), /* size of constraint */
- ConstraintInitialize, /* initialization */
- NULL, /* destroy proc */
- ConstraintSetValues, /* set_values proc */
- NULL, /* extension */
- },
-
- { /* manager_class fields */
- XtInheritTranslations, /* translations */
- NULL, /* syn_resources */
- 0, /* num_syn_resources */
- NULL, /* syn_cont_resources */
- 0, /* num_syn_cont_resources */
- XmInheritParentProcess, /* parent_process */
- NULL, /* extension */
- },
-
- { /* bulletin_board_class fields */
- FALSE, /* always_install_accelerators */
- NULL, /* geo_matrix_create */
- XtInheritFocusMovedProc, /* focus_moved_proc */
- NULL, /* extension */
- },
-
- { /* square_class fields */
- NULL, /* extension */
- }
- };
-
- externaldef(squarewidgetclass) WidgetClass
- squareWidgetClass = (WidgetClass) &squareClassRec;
-
- static XmOffsetPtr square_offsets; /* Part offsets table */
- static XmOffsetPtr square_constraint_offsets; /* Constraint offsets table */
-
- /**********************************************************************
- *
- * SquareCreate - Convenience routine, used by Uil/Mrm.
- *
- *********************************************************************/
-
- Widget SquareCreate(parent, name, arglist, nargs)
- Widget parent;
- char *name;
- Arg *arglist;
- int nargs;
- {
- return(XtCreateWidget (name, squareWidgetClass, parent, arglist, nargs));
- }
-
- /**********************************************************************
- *
- * SquareMrmInitialize - register Square widget class with Mrm
- *
- *********************************************************************/
-
- int SquareMrmInitialize()
- {
- return(MrmRegisterClass (MrmwcUnknown, "Square", "SquareCreate",
- SquareCreate, (WidgetClass)&squareClassRec));
- }
-
- /**********************************************************************
- *
- * Class methods
- *
- *********************************************************************/
-
- static void ClassInitialize()
- {
- XmResolveAllPartOffsets(squareWidgetClass, &square_offsets,
- &square_constraint_offsets);
- }
-
- static void Initialize(req, new)
- SquareWidget req;
- SquareWidget new;
- {
- if (MajorDimension(new) != SquareWIDTH &&
- MajorDimension(new) != SquareHEIGHT) {
- XtWarning("Square: invalid majorDimension");
- MajorDimension(new) = SquareWIDTH;
- }
- }
-
- static Boolean SetValues(curr, req, new)
- SquareWidget curr;
- SquareWidget req;
- SquareWidget new;
- {
- if (MajorDimension(new) != SquareWIDTH &&
- MajorDimension(new) != SquareHEIGHT) {
- XtWarning("Square: invalid majorDimension");
- MajorDimension(new) = MajorDimension(curr);
- }
- return (False);
- }
-
- static void ConstraintInitialize (req, new)
- Widget req;
- Widget new;
- {
- Dimension m;
-
- if(MakeSquare(new) == True) {
- if (MajorDimension(XtParent(new))==SquareWIDTH)
- m = Width(new);
- else
- m = Height(new);
-
- XtResizeWidget(new, m, m, BorderWidth(new));
- }
- }
-
- static Boolean ConstraintSetValues (old, ref, new)
- Widget old;
- Widget ref;
- Widget new;
- {
- Boolean redraw = False;
-
- if (MakeSquare(new) != MakeSquare(old)) {
- if(MakeSquare(new)==True) {
- if (MajorDimension(XtParent(new))==SquareWIDTH)
- Height(new) = Width(new);
- else
- Width(new) = Height(new);
- }
- else {
- XtWidgetGeometry gi;
- XtWidgetGeometry gp;
-
- if (MajorDimension(XtParent(new))==SquareWIDTH)
- Height(new) = Height(new)/2;
- else
- Width(new) = Width(new)/2;
-
- gi.request_mode = CWWidth | CWHeight;
- gi.width = Width(new);
- gi.height = Height(new);
- if (XtQueryGeometry(new, &gi, &gp) == XtGeometryAlmost) {
- if (gp.request_mode && CWWidth != 0) Width(new) = gp.width;
- if (gp.request_mode && CWHeight != 0) Height(new) = gp.height;
- }
- }
- redraw = True;
- }
- return (redraw);
- }
-
-